Skip to content

Conversation

@GAdityaVarma
Copy link
Collaborator

@GAdityaVarma GAdityaVarma commented Jan 7, 2026

Summary

Introduces a centralized TruffleHog secret scanning workflow that automatically scans all pull requests for exposed secrets (API keys, passwords, tokens, etc.) across the organization.

This implementation:

  • Scans PR commits for leaked secrets (API keys, passwords, tokens, etc.)
  • Classifies findings as verified (confirmed active) or unverified (potential match)
  • Posts PR comments with detailed findings when secrets are detected
  • Sets commit status to pass/fail based on scan results

Features

  • Scans only modified files in PRs (fast and efficient)
  • Works with PRs from forks (public and private)
  • Configurable exclusion patterns using regex
  • Supports org-level defaults with repo-level overrides
  • No workflow file needed in individual repos (uses org rulesets)

How It Works

  1. PR is created or updated
  2. Workflow determines PR type (fork vs same-repo)
  3. Fetches PR commits and applies exclusion patterns
  4. Runs TruffleHog scan on the diff between base and head
  5. If secrets found: posts PR comment and fails the check
  6. If no secrets: sets status to success (no comment posted)

Configuration

  • Set TRUFFLEHOG_EXCLUDES variable at org or repo level for custom exclusions
  • Default exclusions include: node_modules, vendor, lock files, minified files

Tested here:
https://github.com/marklogic/copyrighttest/pull/79
https://github.com/marklogic/copyrighttest/pull/78
https://github.com/marklogic/copyrighttest/pull/77

Introduces a centralized GitHub Actions workflow for scanning pull requests for secrets using TruffleHog. Includes a detailed README with setup instructions, exclusion pattern configuration, override options, and troubleshooting guidance.
The workflow now posts PR comments with secret scan findings, sets commit status to pass/fail, and provides clearer merge blocking. Documentation was updated and renamed to trufflehog_readme.md to reflect new features, including secret classification and improved fork PR support.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a centralized TruffleHog secret scanning workflow that automatically validates pull requests across the organization by detecting exposed secrets such as API keys, passwords, and tokens. The workflow runs on all PRs, posts detailed findings as comments when secrets are detected, and sets commit statuses to block merges when necessary.

Key Changes:

  • Implements GitHub Actions workflow with dual triggers (pull_request and pull_request_target) to handle both same-repo and fork PRs
  • Configurable exclusion patterns via TRUFFLEHOG_EXCLUDES variable with org-level defaults and repo-level overrides
  • Automated PR commenting with remediation steps and commit status updates based on scan results

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
trufflehog_readme.md Comprehensive documentation covering setup, configuration, exclusion patterns, workflow triggers, and troubleshooting
.github/workflows/trufflehog-scan.yml GitHub Actions workflow implementing secret scanning with TruffleHog, exclusion handling, result processing, and PR status updates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GAdityaVarma GAdityaVarma requested review from Pragathi-28 and brijeshp56 and removed request for Copilot January 7, 2026 13:33
echo "description=No secrets detected in PR changes" >> $GITHUB_OUTPUT
fi

- name: Post PR comment on findings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a comment? Can't we just rely on annotations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why PR Comments are better for security findings:

  • Immediate visibility - Developers see the alert without extra navigation
  • Actionable - The comment includes remediation steps right there
  • Email notification - PR comment triggers email, ensuring developer sees it
  • Historical record - Comment stays in PR history for auditing
  • Team visibility - Reviewers also see the security issue immediately
  • Mobile-friendly - Easy to check on phone

4. **Push the fix** to this branch

### Finding Details
Check the [workflow run logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like workflow link is already added, please ignore my previous comment and just add the commit ID to the comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the workflow logic to update comments in PR to have commit ID also,

Tested: https://github.com/marklogic/copyrighttest/pull/82
The PR comment now includes the scanned commit SHA with a direct link to the commit.

Example in the comment:

Scanned commit: c0f65d6 (c0f65d61be8cc0c304f25d743b3f1c6536206358)

This lets users verify the scan ran on their latest changes. The comment is also updated on each new push, so the SHA always reflects the most recent scan.

Adds a workflow step to update the PR comment when previously detected secrets are resolved, marking the PR as clear. Updates documentation to clarify that exclusion patterns are additive, describes the new comment update behavior, and improves the remediation and PR comment sections for clarity.
@GAdityaVarma GAdityaVarma reopened this Jan 9, 2026
Enhances the TruffleHog GitHub Actions workflow to better distinguish between scan errors and actual secret findings, adding a verification step for failed scans. Updates documentation to clarify exclusion pattern behavior, workflow triggers, and runtime logic for more accurate and secure secret scanning.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (!hasSecrets) {
// No secrets found
if (existing) {
// Check if existing comment was a critical/blocking one (had verified secrets)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update the PR comment in case developer removes unverified secrets in subsequent commit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants